package com.itdct.onflow.core.vo

import com.itdct.onflow.core.extend.logWarn
import com.itdct.onflow.core.constant.CommonString
import com.itdct.onflow.core.constant.ReturnCode
import io.swagger.v3.oas.annotations.media.Schema


/**
 * @author DCTANT
 * @version 1.0
 * @date 2021/10/14 17:40:38
 * @description 列表返回参数，如果要加额外参数，请继承RespPageVo类
 * 注意！统一返回类型千万不要加上@Schema注解！
 */
class RespPageVo<T> : RespVo<List<T>?> {
    @Schema(title = "分页信息")
    var page: PageInfoVo? = null

    constructor(data: List<T>) {
        logWarn("分页信息丢失！")
        this.data = data
    }

    constructor(data: List<T>, page: PageInfoVo) {
        this.code = ReturnCode.SUCCESS
        this.info = CommonString.SUCCESS
        this.page = page
        this.data = data
    }

    constructor(data: List<T>, pageNum: Long, pageSize: Long, totalCount: Long, totalPage: Long) {
        this.code = ReturnCode.SUCCESS
        this.info = CommonString.SUCCESS
        this.data = data
        val pageInfoVo = PageInfoVo()
        pageInfoVo.pageNum = pageNum
        pageInfoVo.pageSize = pageSize
        pageInfoVo.totalCount = totalCount
        pageInfoVo.totalPage = totalPage
        this.page = pageInfoVo
    }
}
